package com.kingyea.kim.demo.controller;

import com.kingyea.kim.base.Result;
import com.kingyea.kim.demo.bean.Demo;
import com.kingyea.kim.demo.service.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * DEMO
 */
//@CrossOrigin
@RestController
@RequestMapping("/demo")
public class DemoController {

    private final static Logger logger = LoggerFactory.getLogger(DemoController.class);

    @Autowired
    private DemoService demoService;

    /**
     * 根据ID查询对象
     *
     * @param id
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/{id}/select")
    public Result<Demo> select(@PathVariable("id") int id) {
        Result result = new Result();
        logger.info("接收参数ID：" + id);
        Demo demo = demoService.selectById(id);
        result.setModel(demo);
        return result;
    }

}
